Skip to content

fix: croak on trailing dash-option without CODE ref in import#90

Open
Koan-Bot wants to merge 4 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-import-trailing-option
Open

fix: croak on trailing dash-option without CODE ref in import#90
Koan-Bot wants to merge 4 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-import-trailing-option

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 18, 2026

What

Detect and error on incomplete mock declarations in the import() argument list.

Why

use Overload::FileCheck '-e' => sub { 1 }, '-f' silently discarded the trailing -f — the user thinks they're mocking two operators but only one is active. This is a silent data loss bug.

How

Added a post-loop check: if $_next_check is still set after processing all import args, croak with a clear message naming the orphaned option. Also optimized the -B handler in _check_from_stat() to check directory mode bits directly from the cached @stat array instead of dispatching through the full mock system (which triggered a redundant stat callback).

Testing

  • New t/import-trailing-option.t covers both the single-option and trailing-option cases
  • Full test suite passes (1443 subtests)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 49 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

@atoomic atoomic marked this pull request as ready for review April 23, 2026 14:32
@atoomic
Copy link
Copy Markdown
Contributor

atoomic commented Apr 23, 2026

@Koan-Bot rebase

Koan-Bot and others added 2 commits April 23, 2026 08:50
Previously, `use Overload::FileCheck '-e' => sub { 1 }, '-f'` would
silently discard the trailing `-f` option. Now it produces a clear
error message indicating the missing CODE ref.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The -B handler in _check_from_stat() was calling `-d $f_or_fh` to
detect directories, which dispatched through the full mock system and
triggered a second stat callback. Use _check_mode_type() on the
already-fetched @stat array instead — same result, zero extra calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot
Copy link
Copy Markdown
Contributor Author

Rebase with requested adjustments

Branch koan.atoomic/fix-import-trailing-option was rebased onto main and review feedback was applied.

Stats

2 files changed, 49 insertions(+), 1 deletion(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=The -B double-dispatch fix was already landed in de06278, but the primary fix — croaking on a traili)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-import-trailing-option onto upstream/main
  • Pre-push CI check: previous run passed
  • Force-pushed koan.atoomic/fix-import-trailing-option to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-import-trailing-option branch from 54ec32e to 863a11c Compare April 23, 2026 14:50
@atoomic
Copy link
Copy Markdown
Contributor

atoomic commented Apr 23, 2026

view failures from CI

/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- FileCheck.bs blib/arch/auto/Overload/FileCheck/FileCheck.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t .......................... ok
t/01_boot.t .......................... ok
t/02_basic-mock.t .................... ok
t/02_import.t ........................ ok

# Failed test 'Unexpected warning: Use of uninitialized value in numeric eq (==) at /home/runner/work/Overload-FileCheck/Overload-FileCheck/blib/lib/Overload/FileCheck.pm line 353.'
# [No trace info available]
# Seeded srand with seed '20260423' from local date.
t/B-no-double-dispatch.t ............. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests 
t/check-false-vs-null.t .............. ok
t/check-null.t ....................... ok
t/exporter-all.t ..................... ok
t/exporter.t ......................... ok
t/fh-ref-leak.t ...................... ok
t/import-trailing-option.t ........... ok
t/int-errno-preservation.t ........... ok
t/issue-0001.t ....................... ok
t/mock-all-file-checks.t ............. ok
t/mock-all-from-stat.t ............... ok
t/mock-all-from-stat_advanced.t ...... ok
t/mock-all-from-stat_basic.t ......... ok
t/mock-lstat.t ....................... ok
t/mock-setting-errno.t ............... ok
t/mock-stat-hash-bare-keys.t ......... ok
t/mock-stat.t ........................ ok
t/nv-errno-preservation.t ............ ok
t/nv-sentinel-collision.t ............ ok
t/recycle-stat.t ..................... ok
t/reentrant-check.t .................. ok
t/simple-test.t ...................... ok
t/stack-corruption.t ................. ok
t/stat-dispatch-special-types.t ...... ok
t/stat-dispatch-ugk.t ................ ok
t/stat-errno-preservation.t .......... ok
t/stat-helpers-invalid-user-group.t .. ok
t/stat-helpers.t ..................... ok
t/stat-key-normalization.t ........... ok
t/test-A.t ........................... ok
t/test-B-uppercase.t ................. ok
t/test-b.t ........................... ok
t/test-C-uppercase.t ................. ok
t/test-c.t ........................... ok
t/test-d.t ........................... ok
t/test-e-simple.t .................... ok
t/test-e.t ........................... ok
t/test-f.t ........................... ok
t/test-g.t ........................... ok
t/test-integer.t ..................... skipped: This test is designed to be run from one of the symlink: t/test-s.t ...
t/test-k.t ........................... ok
t/test-l.t ........................... ok
t/test-M.t ........................... ok
t/test-O-uppercase.t ................. ok
t/test-o.t ........................... ok
t/test-p.t ........................... ok
t/test-R-uppercase.t ................. ok
t/test-r.t ........................... ok
t/test-S-uppercase.t ................. ok
t/test-s.t ........................... ok
t/test-T-uppercase.t ................. ok
t/test-t.t ........................... ok
t/test-true-false.t .................. skipped: This test is designed to be run from one of the symlink: t/test-e.t ...
t/test-u.t ........................... ok
t/test-W-uppercase.t ................. ok
t/test-w.t ........................... ok
t/test-X-uppercase.t ................. ok
t/test-x.t ........................... ok
t/test-z.t ........................... ok
t/xt-author-check-examples.t ......... ok

Test Summary Report
-------------------
t/B-no-double-dispatch.t           (Wstat: 256 (exited 1) Tests: 5 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
t/mock-all-from-stat_advanced.t    (Wstat: 0 Tests: 209 Failed: 0)
  TODO passed:   6, 18, 28, 41, 75, 155, 166, 177, 188, 199
Files=64, Tests=1523,  5 wallclock secs ( 0.13 usr  0.07 sys +  3.34 cusr  0.85 csys =  4.39 CPU)
Result: FAIL
Failed 1/64 test programs. 1/1523 subtests failed.
make: *** [Makefile:1026: test_dynamic] Error 255

@Koan-Bot rebase

Restored the `@stat &&` guard on line 353 that was dropped during the `-B` refactor. Without it, `$stat[ST_MODE]` is undef when stat returns `[]` (file not found), causing the "Use of uninitialized value in numeric eq" warning that failed `t/B-no-double-dispatch.t` (which uses `Test2::Plugin::NoWarnings`).
@Koan-Bot
Copy link
Copy Markdown
Contributor Author

Rebase with requested adjustments

Branch koan.atoomic/fix-import-trailing-option was rebased onto main and review feedback was applied.

Changes applied

  • Restored the @stat && guard on line 353 that was dropped during the -B refactor. Without it, $stat[ST_MODE] is undef when stat returns [] (file not found), causing the "Use of uninitialized value in numeric eq" warning that failed t/B-no-double-dispatch.t (which uses Test2::Plugin::NoWarnings).
  • CI fix: Applied pre-push CI fix
  • CI fix: Pre-push CI fix applied

Stats

2 files changed, 51 insertions(+), 2 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=None of the recent commits on main address the trailing dash-option without CODE ref silent discard )
  • Rebased koan.atoomic/fix-import-trailing-option onto upstream/main
  • Applied review feedback
  • Pre-push CI check: previous run #24842019617 failed
  • Applied pre-push CI fix
  • Pre-push CI fix applied
  • Force-pushed koan.atoomic/fix-import-trailing-option to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants